package com.haoshuang.zhouzhoubang.ui.dialog

import android.content.Context

import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.haoshuang.zhouzhoubang.R

import com.lxj.xpopup.core.BottomPopupView
import com.mufeng.libs.utils.view.clickWithTrigger


class PayDialog(context: Context, private val onSubmit: (pay_type:Int) -> Unit) : BottomPopupView(context){
    override fun getImplLayoutId(): Int = R.layout.dialog_pay

    override fun initPopupContent() {
        super.initPopupContent()


        var tvButton=findViewById<TextView>(R.id.tvButton)
        var llWx=findViewById<LinearLayout>(R.id.llWx)
        var llZfb=findViewById<LinearLayout>(R.id.llZfb)
        var ivWx=findViewById<ImageView>(R.id.ivWx)
        var ivZfb=findViewById<ImageView>(R.id.ivZfb)
        var pay_type=1
        llWx.clickWithTrigger {
            ivWx.setImageResource(R.mipmap.dz_ok)
            ivZfb.setImageResource(R.mipmap.dz_wx)
            pay_type = 1
        }
        llZfb.clickWithTrigger {
            ivWx.setImageResource(R.mipmap.dz_wx)
            ivZfb.setImageResource(R.mipmap.dz_ok)
            pay_type = 2
        }


        tvButton.setOnClickListener {

            if (pay_type == 1) {
                dismiss()
                onSubmit(pay_type)

            } else {
                dismiss()
                onSubmit(pay_type)
            }

        }
    }


}